<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>  <#include "/common/base_include.ftl"/></head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="col-sm-12">
        <form id="fileForm" name="fileForm" class="form-horizontal" enctype="multipart/form-data" >
            <div class="form-group">
                <label for="filename" class="col-sm-2 control-label">文件</label>
                <div class="col-sm-10">
                    <input type="file" name="filename" id="filename" class="form-control"  multiple="multiple"/>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <input  class="btn-success" type="button" onclick="upload()" value="提交"/>
                </div>
            </div>

        </form>
    </div>
</div>
<script type="text/javascript">
    $(function () {
    });
    function upload() {
        var url = "/luence/file/upload";
        var name = $("input[name=filename]").val();
        //获取文件名的处理方式
        var fileName = name.replace(/^.+?\\([^\\]+?)(\.[^\.\\]*?)?$/gi,"$1");
        //判断是否为空文件
        if (fileName == null || fileName == undefined || fileName == '') {
            $("#submitBtn").attr("disabled", false);
            return;
        }
        var form = $("#fileForm");
        var options = {
            url : url,
            type: 'post',
            success: function (data) {
                console.log(data);
            },
            error: function (data) {
                console.log("上传失败,返回error");
            }
        };
        form.ajaxSubmit(options);
    }
</script>
</body>
</html>